<?php
/**
 * @authors alex (20779512@qq.com)
 * @date    2014-03-24 17:25:39
 * @version 1.0
 */

class MemberAction extends HomeAction {

    #代理中心
    public function index(){
    	$map['id'] = $this->_user['memberID'];
    	$obj = M('Member');
    	$user = $obj->field('id,fid,wxface,userType,wxname,money,guanzhu,userGroup,createTime')->where($map)->find();
    	$user['fname'] = $obj->where('wxid="'.$user['fid'].'"')->getField('wxname');
    	if ($user['fname']=='') {
    		$user['fname'] = C('site_name');
    	}

        if ($user['userType']==0) {
            $user['shenfen'] = '身份：普通会员';
        }else if($user['userType']==1){
            $user['shenfen'] = '身份：业务员';
        }else if($user['userType']==2){
            $user['shenfen'] = '身份：商家会员';
        }  

    	$beginDate = strtotime(date("Y-m-1"));
        $beginStr = date("Y-m-d",$beginDate);
        $endDate = strtotime("$beginStr +1 month -1 day");
        unset($map);
        $map['createTime'] = array('between',array($beginDate,$endDate));
        $map['memberID'] = $this->_user['memberID'];
        $sign = M('Sign')->where($map)->getField('id,signDate');

        if (in_array(date("Y-m-d"),$sign)) {
            $flag = '1';
        }else{
            $flag = '0';
        }
        $this->assign('flag',$flag);


		$obj = M('Order');
		//未支付
		unset($map);
		$map['memberID'] = $this->_user['memberID'];
		$map['payStatus'] = 0;
		$map['del'] = 0;
		$nopay = $obj->where($map)->count();

		//已支付
		unset($map);
		$map['memberID'] = $this->_user['memberID'];
		$map['payStatus'] = 1;
		$map['del'] = 0;
		$yespay = $obj->where($map)->count();

		//未评论		
		unset($map);
		$map['memberID'] = $this->_user['memberID'];
		$map['payStatus'] = 1;
		$map['del'] = 0;
		$order_no = M('Order')->where($map)->getField('id,order_no');

		unset($map);
		$map['order_no'] = array('in',$order_no);
		$map['comment'] = 0;
		$nocomment = M('OrderDetail')->where($map)->count();

		$this->assign('nopay',$nopay);
		$this->assign('yespay',$yespay);
		$this->assign('nocomment',$nocomment);
    	$this->assign('user',$user);
        $this->display();        
    }

    
}